package com.example.shop_management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shop_management.entity.Admin;
import com.example.shop_management.service.AdminService;
import com.example.shop_management.mapper.AdminMapper;
import com.example.shop_management.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author cy
* @description 针对表【sys_admin】的数据库操作Service实现
* @createDate 2022-05-13 16:44:23
*/
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin>
    implements AdminService{

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin login(Admin admin) {
        QueryWrapper<Admin> adminQueryWrapper = new QueryWrapper<>();
        adminQueryWrapper.eq("username",admin.getUsername());
        String enteredPassword = MD5Util.getMD5(admin.getPassword());
        adminQueryWrapper.eq("password",enteredPassword);
        Admin one = getOne(adminQueryWrapper);
        return one;
    }

}




